//
//  MBCommodityDetailTipsView.swift
//  iPhone
//
//  Created by Toj on 8/11/22.
//

import UIKit

class MBCommodityDetailTipsView: UIView {
    
    var model: NSObject? {
        didSet {
            // guard let info = model else { return }
            
            tipsLabel.text = "As you are a new member, we give you an 80% discount"
            introduceLabel.text = "* Access to All Channel&VODs, Unlimited for 3 months, UEL, \n* FA Cap, Copa del Rey, Bundesliga, NBA, Fox, Colors."
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupMakeAddSubviews()
        setupMakeInitialize()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        setupMakeLayoutSubviews()
    }
    
    // 提示
    private lazy var tipsLabel: UILabel = {
        let view = UILabel()
        view.numberOfLines = 0
        view.textColor = "#99773C".to_color
        view.font = UIFont.systemFont(ofSize: 12)
        return view
    }()
    
    // 提示背景
    private lazy var tipsView: UIView = {
        let view = UIView()
        view.cm_cornerRadius = 4
        view.backgroundColor = "#FFFAEE".to_color
        view.cm_border(color: "#E8CD8C".to_color)
        return view
    }()
    
    // 介绍
    private lazy var introduceLabel: UILabel = {
        let view = UILabel()
        view.numberOfLines = 0
        view.textColor = "#999999".to_color
        view.font = UIFont.systemFont(ofSize: 12)
        return view
    }()
}

// MARK: - 初始化
extension MBCommodityDetailTipsView {
    
    private func setupMakeAddSubviews() {
        
        addSubview(tipsView)
        addSubview(tipsLabel)
        addSubview(introduceLabel)
    }
    
    private func setupMakeLayoutSubviews() {
        
        tipsLabel.snp.makeConstraints { make in
            make.top.equalTo(8)
            make.left.equalTo(8)
            make.right.equalTo(snp.right).offset(-8)
        }
        
        tipsView.snp.makeConstraints { make in
            make.left.top.right.equalTo(self)
            make.bottom.equalTo(tipsLabel.snp.bottom).offset(8)
        }
        
        introduceLabel.snp.makeConstraints { make in
            make.top.equalTo(tipsView.snp.bottom).offset(8)
            make.left.right.equalTo(tipsView)
        }
    }
    
    private func setupMakeInitialize() {
        model = nil
    }
}
